﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace TekaMUD.Engine.Framework
{
	// Crypto functions
	public class Crypto
	{
		public static byte[] GetMD5Hash(string str)
		{
			MD5 md5 = new MD5CryptoServiceProvider();
			return md5.ComputeHash(Encoding.Default.GetBytes(str));
		}

		public static bool CompareHashes(byte[] h1, byte[] h2)
		{
			if (h1 == null || h2 == null || h1.Length != h2.Length)
				return false;

			for (int i = 0; i < h1.Length; i++)
				if (h1[i] != h2[i])
					return false;

			return true;
		}
	}
}
